package idv.takeshi.software.productline.bookstore.domain.model.order;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * A model class as a payment to indicate that it shall be paid by ATM.
 * @author takeshi
 *
 */
@Entity
@Table(name = "ATM")
public class Atm extends BeforeDeliveryPayment {
	
	@Column(length = 3, name = "TRANS_BANK_ID")
	private String transferBankId;
	@Column(length = 16, name = "TRANS_ACCOUNT_NO") 
	private String transferAccountNumber;
	
	@Column(length = 3, name = "DEPOSIT_BANK_ID")
	private String depositForBankId;
	@Column(length = 16, name = "DEPOSIT_ACCOUNT_NO")
	private String depositForAccountNumber;

	/**
	 * @return the transferBankId
	 */
	public String getTransferBankId() {
		return transferBankId;
	}

	/**
	 * @param transferBankId the transferBankId to set
	 */
	public void setTransferBankId(String transferBankId) {
		this.transferBankId = transferBankId;
	}

	/**
	 * @return the transferAccountNumber
	 */
	public String getTransferAccountNumber() {
		return transferAccountNumber;
	}

	/**
	 * @param transferAccountNumber the transferAccountNumber to set
	 */
	public void setTransferAccountNumber(String transferAccountNumber) {
		this.transferAccountNumber = transferAccountNumber;
	}

	/**
	 * @return the depositForBankId
	 */
	public String getDepositForBankId() {
		return depositForBankId;
	}

	/**
	 * @param depositForBankId the depositForBankId to set
	 */
	public void setDepositForBankId(String depositForBankId) {
		this.depositForBankId = depositForBankId;
	}

	/**
	 * @return the depositForAccountNumber
	 */
	public String getDepositForAccountNumber() {
		return depositForAccountNumber;
	}

	/**
	 * @param depositForAccountNumber the depositForAccountNumber to set
	 */
	public void setDepositForAccountNumber(String depositForAccountNumber) {
		this.depositForAccountNumber = depositForAccountNumber;
	}

	/* (non-Javadoc)
	 * @see idv.takeshi.software.productline.bookstore.domain.model.order.Payment#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj == null) { return false; }
		   if (obj == this) { return true; }
		   if (!(obj instanceof Atm)) {
		     return false;
		   }
		   Atm rhs = (Atm) obj;
		   return new EqualsBuilder()
		   	   .appendSuper(super.equals(rhs))
			   .append(this.transferBankId, rhs.transferBankId)
			   .append(this.transferAccountNumber, rhs.transferAccountNumber)
			   .append(this.depositForBankId, rhs.depositForBankId)
			   .append(this.depositForAccountNumber, rhs.depositForAccountNumber)
		       .isEquals();
	}

	/* (non-Javadoc)
	 * @see idv.takeshi.software.productline.bookstore.domain.model.order.Payment#hashCode()
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder(19, 97).
		   appendSuper(super.hashCode()).
	       append(this.transferBankId).
	       append(this.transferAccountNumber).
	       append(this.depositForBankId).
	       append(this.depositForAccountNumber).
	       toHashCode();
	}
	 
}
 
